<?php

/*	Vulpes - Web-based managegent for wireless internet providers.
	Copyright (C) 2007 LinFox Serviços em Informática Ltda.

	This file is part of Vulpes.

	Vulpes is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	Vulpes is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>. */

class page
{
	var $title;
	var $action;
	var $user;
	var $errors;
	var $warnings;
	var $notifications;
	var $content = '';
	
	function __construct()
	{
		header('Content-Type: text/xml; charset=utf-8');
		header('Cache-control: private');
		
		global $conf;

		$this->action = get('action');
		$this->title = $conf['sitename'];
	}

	function add_nav()
	{
		return false;
	}
	
	function display()
	{
		global $header;
		global $footer;

		echo $this->parse
		(
			$header .
			$this->content .
			'<errors>' .$this->errors. '</errors>' .
			'<warnings>' .$this->warnings. '</warnings>' .
			'<notifications>' .$this->notifications. '</notifications>' .
			$footer
		);
	}
	
	function parse($result)
	{
		global $lang;
		global $conf;

		$result = str_replace('{vulpes_site_name}', $conf['sitename'], $result);

		for (reset($lang); $translation = current($lang); next($lang))
		{
			$result = str_replace('{lang_' .key($lang). '}', $translation, $result);
		}
		
		return $result;
	}

	function error($message, $description = '', $code = '')
	{
		$this->errors .= '
			<error>
				<message>' .$message. '</message>
				<description>' .$description. '</description>
				<code>' .$code. '</code>
			</error>';
	}
	function warning($message)
	{
		$this->warnings .= '<warning>' .$message. '</warning>';
	}
	function notify($message)
	{
		$this->notifications .= '<notification>' .$message. '</notification>';
	}
}

?>